package controllers.playsienauser;

import play.Play;
import play.mvc.Before;
import play.mvc.Controller;
import play.mvc.Util;

public class TransportUriGuaranteeController extends Controller {

	/**
	 * Scenario:
	 * 
	 * You want to force user to use https instead of http for login (and maybe other critical stuff).
	 */
	@Before
	static void redirectToFixedUrlWhenSet() {
		
		String fixedUrl = Play.configuration.getProperty(
				"playsienauser.fixedUrl", "");
		
		//is the parameter set in application.conf?
		if (!fixedUrl.equals("")) {
			
			//parameter set => now redirect when we are not on that server:
			if (!fixedUrl.startsWith(request.getBase())) {
			
				redirect(fixedUrl + request.path);
			}
		
			
		}
		
	}
}
